﻿using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace RimZombieGirl
{
    /// <summary>
    /// 让 Ability 不再显示原生施放 Gizmo，只显示来自实现了 IAbilityGizmoProvider 的 comps 的 Gizmo。
    /// </summary>
    public class Ability_NoCastGizmo : Ability
    {
        public Ability_NoCastGizmo() { }
        public Ability_NoCastGizmo(Pawn pawn) : base(pawn) { }
        public Ability_NoCastGizmo(Pawn pawn, AbilityDef def) : base(pawn, def) { }

        public override IEnumerable<Command> GetGizmos()
        {
            if (this.comps != null)
            {
                for (int i = 0; i < this.comps.Count; i++)
                {
                    if (this.comps[i] is IAbilityGizmoProvider provider)
                    {
                        foreach (var g in provider.GetGizmos(this))
                            yield return g;
                    }
                }
            }
            yield break;
        }
    }

    /// <summary>
    /// 任何希望为 Ability 提供 Gizmo 的 Comp，可以实现这个接口。
    /// </summary>
    public interface IAbilityGizmoProvider
    {
        IEnumerable<Command> GetGizmos(Ability ability);
    }
}
